home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Caml Light 0.7 / Caml Light 0.7 source / src / tools / scanmsgs.mll < prev   
Text File  |  1995-06-01  |  1KB  |  44 lines

  1. (* Extract all strings given to interntl__e?printf in a source file *)
  2.  
  3. {
  4. let char_for_decimal_code lexbuf i =
  5.   char_of_int(100 * (int_of_char(get_lexeme_char lexbuf i) - 48) +
  6.                10 * (int_of_char(get_lexeme_char lexbuf (i+1)) - 48) +
  7.                     (int_of_char(get_lexeme_char lexbuf (i+2)) - 48))
  8. ;;
  9.  
  10. let interntl_is_open = ref false;;
  11. }
  12.  
  13. rule main = parse
  14.     "#open" [` ` `\010` `\013` `\009` `\012`] * "\"interntl\""
  15.       { interntl_is_open := true; main lexbuf }
  16.   | "interntl__" ( `e`? "printf" | "translate")
  17.     [` ` `\010` `\013` `\009` `\012`] * `"`
  18.       { string lexbuf; main lexbuf }
  19.   | `e`? "printf" [` ` `\010` `\013` `\009` `\012`] * `"`
  20.       { if !interntl_is_open then string lexbuf;
  21.         main lexbuf }
  22.   | "fprintf" [` ` `\010` `\013` `\009` `\012`] *
  23.     [`a`-`z``A`-`Z`] + [` ` `\010` `\013` `\009` `\012`] * `"`
  24.       { if !interntl_is_open then string lexbuf;
  25.         main lexbuf }
  26.   | eof { () }
  27.   | _ { main lexbuf }
  28.  
  29. and string = parse
  30.     `"`
  31.       { print_string "\n\n" }
  32.   | "\\\n" [` ` `\t`] *
  33.       { print_string "\\\n"; string lexbuf }
  34.   | "\\\""
  35.       { print_string "\"";
  36.         string lexbuf }
  37.   | eof
  38.       { prerr_endline "Warning: string not terminated" }
  39.   | _
  40.       { print_char(get_lexeme_char lexbuf 0);
  41.         string lexbuf }
  42. ;;
  43.  
  44.